#!/usr/bin/perl -w
use strict;
use Bio::DB::Taxonomy;

my $idx_dir = '.';

my ( $nodefile, $namesfile ) = ( 'nodes.dmp', 'names.dmp' );
my $db = new Bio::DB::Taxonomy(
	-source    => 'flatfile',
	-nodesfile => $nodefile,
	-namesfile => $namesfile,
	-directory => $idx_dir
);
my $node = $db->get_Taxonomy_Node( -taxonid => '33090' );
print $node->id, " ", $node->scientific_name, " ", $node->rank, "\n";

# to only get children that are of a particular rank in the taxonomy test if their rank is 'species' for example
my @extant_children = grep { $_->rank eq 'species' } $node->get_all_Descendents;

for my $child (@extant_children) {
	print "id is ",              $child->id,              "\n";  # NCBI taxa id
	print "rank is ",            $child->rank,            "\n";  # e.g. species
	print "scientific name is ", $child->scientific_name, "\n";  # scientific name
}
